package com.stx.servlet.park;

import com.stx.bean.LoginUser;
import com.stx.bean.Parking;
import com.stx.mapper.LoginUserMapper;
import com.stx.mapper.ParkingMapper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(urlPatterns = {"/addPark"})
public class AddParkServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String place = req.getParameter("place");
        String state = req.getParameter("state");
        String size = req.getParameter("size");
        Parking park = new Parking(0,place,state,size);
        try {
            ParkingMapper.addPark(park);
            resp.sendRedirect("/parkinglist");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }

}
